﻿<?php 
$v_page = $_SESSION['v_session_page'];
$v_limit_row = $_SESSION['v_session_limit_num_page'];
// Luu ten style hien thoi
$v_current_style_name = "odd_row";
// Luu ten style tiep theo
$v_next_style_name = "";
$v_record_doc_id = 0;
if(isset($_REQUEST['hdn_record_doc_id'])){
	$v_record_doc_id = intval($_REQUEST['hdn_record_doc_id']);
}

$v_staff_id = _get_item_attr_by_id ($_SESSION['arr_all_staff'],$_SESSION['staff_id'],'id');
$v_recordtype_filter = $_SESSION['onegate_current_recordtype'];
//var_dump ($arr_all_recordtype);
for($i=0;$i<sizeof($arr_all_recordtype);$i++){
	if ($arr_all_recordtype[$i]['C_NAME'] == $v_recordtype_filter){
		$v_recordtype_id = $arr_all_recordtype[$i]['PK_RECORDTYPE'];
	}
}

$v_current_status = ($arr_single_record['C_CURRENT_STATUS']);
$v_detail_status = intval($arr_single_record['C_DETAIL_STATUS']);

//Kiem tra NSD hien thoi dong vai tro la thu ly chinh hoac nguoi phoi hop thu ly doi voi ho so hien thoi va trang thai cua ho so la "DANG_THU_LY" va C_DETAIL_STATUS <>20
if ( ((onegate_is_main_handler_for_record($v_staff_id,$v_record_id))|| (onegate_is_co_handler_for_record($v_staff_id,$v_record_id)) )&&  $v_current_status == "DANG_THU_LY" && $v_detail_status <> 20){
	$v_is_main_or_co_handler_for_record_and_status = 1;
}else{
	$v_is_main_or_co_handler_for_record_and_status = 0;
}
?>
<!--bang chua tieu de cua form-->
<table width="100%" cellpadding="0" cellspacing="0">
	<tr class="normal_title">
		<td>
			<?php echo CONST_RECORD_DOC_TITLE; ?>
			<a id="goto" href="" style=".color:white">#</a>
		</td>
	</tr>
</table>
<!-- bang chua cac tieu thuc loc-->
<table cellpadding="0" cellspacing="0" width="100%" >								
	<tr>
	 	<form action="index.php" name="frm_record_doc" method="post">
		<input type="hidden" name="fuseaction"  value="">
		<input type="hidden" name="hdn_record_doc_id"  value="<?php //echo $v_work_id; ?>">		
		<input type="hidden" name="hdn_record_id"  value="<?php echo $v_record_id; ?>">
		<input type="hidden" name="hdn_record_doc_id_list"  value="">
		<input type='hidden' name='hdn_page' value='<?php echo $v_page;?>'>
		<input type='hidden' name='hdn_record_number_page' value='<?php echo $v_limit_row;?>'>
	</tr>
</table>
<table cellpadding="0" class="form_table1" cellspacing="0" width="100%">
	<tr>
		<td><?php echo onegate_show_record_general_info($arr_single_record,$_SESSION['recordtype'],true,$p_petition_link,$p_rate_of_progress_link,$p_document_link,$p_idea_link,$p_notify_link,$p_sign_link,$p_approve_link,$p_licensing_link,$v_url_view_update_record_status); ?></td>
	</tr>
	<tr>
		<td>		
			<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
				<col width="5%"><col width="15%"><col width="30%"><col width="35%"><col width="15%">
					<tr class="header">
					<td>#</td>
					<td><?php echo CONST_RECORD_DOC_CODE_LABEL; ?></td>
					<td><?php echo CONST_RECORD_DOC_NAME_LABEL; ?></td>
					<td><?php echo CONST_RECORD_DOC_ISSUE_AGENCY_LABEL; ?></td>
					<td><?php echo CONST_RECORD_DOC_DATE_LABEL; ?></td>
				</tr>
			</table>	
			<div style="overflow: auto; width: 100%; height:<?php echo _CONST_HEIGHT_OF_LIST?>;padding-left:0px;margin:0px">
			<table class="list_table2" width="100%" cellpadding="0" cellspacing="0">
				<col width="5%"><col width="15%"><col width="30%"><col width="35%"><col width="15%">
				<?php 
				if ($v_count_record_doc>0){
					for($row_index = 0;$row_index< $v_count_record_doc ;$row_index++){
						$v_doc_id = $arr_record_doc[$row_index]['PK_RECORD_DOC'];
						$v_name =_replace_bad_char($arr_record_doc[$row_index]['C_NAME']);
						$v_code = _replace_bad_char($arr_record_doc[$row_index]['C_CODE']);
						$v_date = _yyyymmdd_to_ddmmyyyy($arr_record_doc[$row_index]['C_DATE']);			
						$v_promulgate = _replace_bad_char($arr_record_doc[$row_index]['C_ISSUE_AGENCY']);
			
						$v_url = "row_onclick(" . "document.frm_record_doc.hdn_record_doc_id"  .  "," . $v_doc_id . "," . "'DISPLAY_SINGLE_RECORD_DOC','" . $v_goto_url . "')";
						if ($v_current_style_name == "odd_row"){
							$v_current_style_name = "round_row";
						}else{
							$v_current_style_name = "odd_row";
						}?>	
						<tr class="<?php echo $v_current_style_name ?>"> 
							<td align="center">
								<input type="checkbox" name="chk_doc_id" value="<?php echo $v_doc_id; ?>">
							</td>
							<td align="center" onClick="<?php echo $v_url;?>">
								<a name="<?php echo $v_doc_id;?>"><?php echo $v_code;?></a>
							</td>	
							<td align="left" onClick="<?php echo $v_url;?>">
								<a name="<?php echo $v_doc_id;?>"><?php echo $v_name;?></a>
							</td>	
							<td align="left" onClick="<?php echo $v_url;?>">
								<a name="<?php echo $v_doc_id;?>"><?php echo $v_promulgate."<br>";?></a>					
							</td>	
							<td align="center" onclick="<?php echo $v_url ;?>">
								<a name="<?php echo $v_doc_id;?>"><?php echo $v_date; ?></a>
							</td>
						</tr><?php 
					}	
				}
				if ($v_current_style_name == "odd_row"){
					$v_next_style_name = "round_row";
				}else{
					$v_next_style_name = "odd_row";
				}
				echo _add_empty_row($v_count_record_doc,_CONST_NUMBER_OF_ROW_PER_LIST,$v_current_style_name,$v_next_style_name,5);
				?>
			</table>
		</div>
		</td>
	</tr>							
</table>
<table align="center">
	<tr><td height="5"></td></tr>
	<tr>
		<td><?php
			if (($v_is_granted_update) 
				|| (onegate_is_receiver_for_recordtype($v_staff_id,$v_recordtype_id,$_SESSION["recordtype"])) 
				|| ($v_is_main_or_co_handler_for_record_and_status > 0)
				//Kiem tra NSD hien thoi co quyen duoc cap nhat tien do cong viec khong?
				|| (onegate_is_permission_update_rate_of_progress_for_recordtype($v_staff_id,0,$_SESSION["recordtype"]))
			){ ?>
				<input type="button" value="<?php echo _CONST_ADD_BUTTON; ?>" name="btn_add" class="normal_button" onClick="btn_add_onclick(document.forms(0).hdn_record_doc_id, 'DISPLAY_SINGLE_RECORD_DOC')"><?php
			}	
			if ( ($v_is_granted_update) 
					|| (onegate_is_receiver_for_recordtype($v_staff_id,$v_recordtype_id,$_SESSION["recordtype"])) 
					|| (onegate_is_main_handler_for_record($v_staff_id,$v_record_id)) 
					//Kiem tra NSD hien thoi co quyen duoc cap nhat tien do cong viec khong?
					|| (onegate_is_permission_update_rate_of_progress_for_recordtype($v_staff_id,0,$_SESSION["recordtype"]))					
				){ ?>
				<input type="button" value="<?php echo _CONST_DELETE_BUTTON; ?>" name="btn_delete" class="normal_button" onClick="btn_delete_onclick(document.forms(0).chk_doc_id,document.forms(0).hdn_record_doc_id_list,'DELETE_RECORD_DOC')"><?php
			}?><!--
			<input type="button" value="<?php echo _CONST_BACK_BUTTON; ?>" name="btn_add" class="normal_button" onClick="<?php echo $_URL_BACK?>">
			-->
		</td>
	</tr>
</table>
</form>
